package com.zx.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zx.pm.service.ReviewProjectService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zx.common.annotation.Log;
import com.zx.common.core.controller.BaseController;
import com.zx.common.core.domain.AjaxResult;
import com.zx.common.enums.BusinessType;
import com.zx.pm.domain.ReviewProject;
import com.zx.common.utils.poi.ExcelUtil;
import com.zx.common.core.page.TableDataInfo;

/**
 * 评审项目信息Controller
 *
 * @author ruoyi
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/pm/review")
public class ReviewProjectController extends BaseController
{
    @Autowired
    private ReviewProjectService reviewProjectService;

    /**
     * 查询评审项目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReviewProject reviewProject)
    {
        startPage();
        List<ReviewProject> list = reviewProjectService.selectReviewProjectList(reviewProject);
        return getDataTable(list);
    }

    /**
     * 导出评审项目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:export')")
    @Log(title = "评审项目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReviewProject reviewProject)
    {
        List<ReviewProject> list = reviewProjectService.selectReviewProjectList(reviewProject);
        ExcelUtil<ReviewProject> util = new ExcelUtil<ReviewProject>(ReviewProject.class);
        util.exportExcel(response, list, "评审项目信息数据");
    }

    /**
     * 获取评审项目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(reviewProjectService.selectReviewProjectById(id));
    }

    /**
     * 新增评审项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:add')")
    @Log(title = "评审项目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReviewProject reviewProject)
    {
        return toAjax(reviewProjectService.insertReviewProject(reviewProject));
    }

    /**
     * 修改评审项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:edit')")
    @Log(title = "评审项目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReviewProject reviewProject)
    {
        return toAjax(reviewProjectService.updateReviewProject(reviewProject));
    }

    /**
     * 删除评审项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:remove')")
    @Log(title = "评审项目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(reviewProjectService.deleteReviewProjectByIds(ids));
    }
}
